import unittest
import HTMLTestRunner
import os
import time

# 测试报告路径
report_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# 测试报告⽂件名
html_report_filename = time.strftime("back_add_goods %Y-%m-%d %H-%M-%S") + '-HTMLReport.html'
html_report_path = os.path.join(report_path, "report", html_report_filename)
# 测试套件
loader = unittest.defaultTestLoader.discover("../case/backstage", pattern='test_back_add_goods*')
with open(html_report_path, 'wb') as f:
    runner = HTMLTestRunner.HTMLTestRunner(
        tester='弓长马也',
        title='商品管理-添加新商品',
        description='商品管理-添加新商品自动化测试报告',
        stream=f,
        verbosity=2
    )
    runner.run(loader)
